package com.efruit.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.efruit.externalInterfaces.IProductInfoMag;
import com.efruit.struts.form.DeleteProductInfoForm;

public class DeleteProductInfoAction extends Action{
	
	IProductInfoMag productInfoMag = null;
	
	public IProductInfoMag getProductInfoMag() {
		return productInfoMag;
	}

	public void setProductInfoMag(IProductInfoMag productInfoMag) {
		this.productInfoMag = productInfoMag;
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		System.out.println("enter DeleteProductInfoAction");
		DeleteProductInfoForm deleteForm = (DeleteProductInfoForm)form;
		System.out.println(deleteForm.getId());
		try {
			productInfoMag.remove(deleteForm.getId());
			System.out.println("after DeleteProductInfoAction");
			return mapping.findForward("listProductInfo");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("error");
		}
	}
}
